Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(synapse-interface): format portfolio balances #2832

Merged
merged 5 commits into from
Jul 17, 2024

Conversation

bigboydiamonds
Copy link
Collaborator

@bigboydiamonds bigboydiamonds commented Jul 2, 2024

Summary by CodeRabbit

  • Enhancements
    • Improved balance formatting across multiple components for better readability using formatAmount.
    • Simplified balance display logic within GasTokenAsset.
    • Enhanced PortfolioTokenVisualizer to support chain-specific token balances via portfolioChainId prop.
    • Updated SingleNetworkPortfolio to pass portfolioChainId to PortfolioTokenVisualizer.
    • Improved display of maxBridgeableBalance in AvailableBalance by formatting with formatAmount.

de80720: synapse-interface preview link
71bd1a6: synapse-interface preview link
cef13dc: synapse-interface preview link

Copy link
Contributor

coderabbitai bot commented Jul 2, 2024

Walkthrough

A series of updates have been made across multiple files to improve consistency and functionality in the Synapse Interface project. Key enhancements include the unified importation of HoverTooltip and the introduction of formatAmount function for formatting balances. Additionally, portfolioChainId has been integrated into relevant components to better manage token balances for different chains.

Changes

Files/Components Change Summary
GasTokenAsset.tsx Updated HoverTooltip import and integrated formatAmount for balance display.
PortfolioTokenVisualizer.tsx Modified imports and added portfolioChainId prop to compute token balances.
SingleNetworkPortfolio.tsx Passed portfolioChainId prop to PortfolioTokenVisualizer.
StateManagedBridge/AvailableBalance.tsx Imported formatAmount and applied it to format maxBridgeableBalance.

Poem

In the realm of tokens, balances found,
New imports and props tightly wound.
With HoverTooltip and formatAmount in play,
Correct amounts now on display.
Chains identified with care,
portfolioChainId is there,
Synapse flows in harmony, everywhere.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@bigboydiamonds bigboydiamonds changed the title fix(synapse-interface): format portfolio balances chore(synapse-interface): format portfolio balances Jul 2, 2024
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

  • Updated balance formatting logic in packages/synapse-interface/components/Portfolio/components/GasTokenAsset.tsx using formatAmount
  • Improved balance formatting in packages/synapse-interface/components/Portfolio/components/PortfolioTokenVisualizer.tsx with getParsedBalance and formatAmount
  • Passed portfolioChainId prop to PortfolioTokenVisualizer in packages/synapse-interface/components/Portfolio/components/SingleNetworkPortfolio.tsx
  • Formatted maxBridgeableBalance in packages/synapse-interface/components/StateManagedBridge/AvailableBalance.tsx using formatAmount
  • Added console log for maxBridgeableBalance in packages/synapse-interface/components/StateManagedBridge/AvailableBalance.tsx for debugging

4 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Outside diff range and nitpick comments (3)
packages/synapse-interface/components/StateManagedBridge/AvailableBalance.tsx (1)

Line range hint 37-44: Omit the Else Clause

The else clause can be omitted because previous branches return early. This improves readability.

-  } else if (isGasToken && isGasEstimateLoading) {
+  }
+  if (isGasToken && isGasEstimateLoading) {
Tools
Biome

[error] 29-44: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 37-44: This else clause can be omitted because previous branches break early.

(lint/style/noUselessElse)

packages/synapse-interface/components/Portfolio/components/SingleNetworkPortfolio.tsx (2)

Line range hint 103-103: Add rel="noreferrer" to External Link

Opening external links in new tabs without rel="noreferrer" is a security risk.

-  <a target="_blank" className="underline" href={TWITTER_URL}>
+  <a target="_blank" rel="noreferrer" className="underline" href={TWITTER_URL}>

Line range hint 107-107: Add rel="noreferrer" to External Link

Opening external links in new tabs without rel="noreferrer" is a security risk.

-  <a target="_blank" className="underline" href={DISCORD_URL}>
+  <a target="_blank" rel="noreferrer" className="underline" href={DISCORD_URL}>
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d0f1508 and 908dac6.

Files selected for processing (4)
  • packages/synapse-interface/components/Portfolio/components/GasTokenAsset.tsx (3 hunks)
  • packages/synapse-interface/components/Portfolio/components/PortfolioTokenVisualizer.tsx (7 hunks)
  • packages/synapse-interface/components/Portfolio/components/SingleNetworkPortfolio.tsx (1 hunks)
  • packages/synapse-interface/components/StateManagedBridge/AvailableBalance.tsx (3 hunks)
Additional context used
Biome
packages/synapse-interface/components/StateManagedBridge/AvailableBalance.tsx

[error] 29-44: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 37-44: This else clause can be omitted because previous branches break early.

(lint/style/noUselessElse)

packages/synapse-interface/components/Portfolio/components/SingleNetworkPortfolio.tsx

[error] 103-103: Avoid using target="_blank" without rel="noreferrer".

Opening external links in new tabs without rel="noreferrer" is a security risk. See the explanation for more details.
Safe fix: Add the rel="noreferrer" attribute.

(lint/a11y/noBlankTarget)


[error] 107-107: Avoid using target="_blank" without rel="noreferrer".

Opening external links in new tabs without rel="noreferrer" is a security risk. See the explanation for more details.
Safe fix: Add the rel="noreferrer" attribute.

(lint/a11y/noBlankTarget)

Additional comments not posted (15)
packages/synapse-interface/components/StateManagedBridge/AvailableBalance.tsx (2)

3-3: Import Statement Approved

The import statement for formatAmount is correctly added.


41-41: Correct Usage of formatAmount

The usage of formatAmount to format maxBridgeableBalance is correct.

packages/synapse-interface/components/Portfolio/components/GasTokenAsset.tsx (3)

5-6: Import Statements Approved

The import statements for HoverTooltip and formatAmount are correctly added.


17-17: Correct Usage of getParsedBalance

The usage of getParsedBalance to parse the balance is correct.


42-42: Correct Usage of formatAmount

The usage of formatAmount to format parsedBalance is correct.

packages/synapse-interface/components/Portfolio/components/PortfolioTokenVisualizer.tsx (9)

3-5: Import Statements Approved

The import statements for HoverTooltip, getParsedBalance, and formatAmount are correctly added.


9-12: New Prop portfolioChainId Approved

The addition of portfolioChainId as a prop is correctly implemented.


25-28: Correct Usage of getParsedBalance for First Token

The usage of getParsedBalance to parse the balance of the first token is correct.


29-32: Correct Usage of getParsedBalance for Second Token

The usage of getParsedBalance to parse the balance of the second token is correct.


55-55: Correct Usage of formatAmount for First Token

The usage of formatAmount to format the balance of the first token is correct.


72-72: Correct Usage of formatAmount for Single Token

The usage of formatAmount to format the balance of a single token is correct.


81-81: Correct Usage of formatAmount for Second Token

The usage of formatAmount to format the balance of the second token is correct.


103-106: Correct Usage of getParsedBalance for Additional Tokens

The usage of getParsedBalance to parse the balance of additional tokens is correct.


109-109: Correct Usage of formatAmount for Additional Tokens

The usage of formatAmount to format the balance of additional tokens is correct.

packages/synapse-interface/components/Portfolio/components/SingleNetworkPortfolio.tsx (1)

91-93: Correct Passing of portfolioChainId Prop

The portfolioChainId prop is correctly passed to PortfolioTokenVisualizer.

Copy link

cloudflare-workers-and-pages bot commented Jul 2, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8151cde
Status: ✅  Deploy successful!
Preview URL: https://8f404688.sanguine-fe.pages.dev
Branch Preview URL: https://fix-format-balance.sanguine-fe.pages.dev

View logs

Copy link

codecov bot commented Jul 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 25.71313%. Comparing base (ac2fa5d) to head (8151cde).
Report is 4 commits behind head on master.

Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #2832         +/-   ##
===================================================
+ Coverage   23.56910%   25.71313%   +2.14403%     
===================================================
  Files            679         709         +30     
  Lines          50842       52094       +1252     
  Branches          80          80                 
===================================================
+ Hits           11983       13395       +1412     
+ Misses         37536       37323        -213     
- Partials        1323        1376         +53     
Flag Coverage Δ
cctp-relayer ?
packages 90.47619% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

(updates since last review)

  • Removed console log statement in packages/synapse-interface/components/StateManagedBridge/AvailableBalance.tsx
  • Used formatAmount utility function for balance display in packages/synapse-interface/components/StateManagedBridge/AvailableBalance.tsx

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range and nitpick comments (1)
packages/synapse-interface/components/StateManagedBridge/AvailableBalance.tsx (1)

Line range hint 35-42: Omit unnecessary else clauses.

The else clauses can be omitted because the previous branches return early. This will simplify the code and improve readability.

  if (isDisabled) {
    return null
  }
  
  if (isGasToken && isGasEstimateLoading) {
    return (
      <label className={labelClassName} htmlFor="inputRow">
        <span className="animate-pulse text-zinc-500 dark:text-zinc-400">
          calculating gas...
        </span>
      </label>
    )
  }
  
  return (
    <label className={labelClassName} htmlFor="inputRow">
      <span className="text-zinc-500 dark:text-zinc-400">Available: </span>
      {formatAmount(maxBridgeableBalance?.toString()) ?? balance ?? '0.0'}
    </label>
  )
Tools
Biome

[error] 27-42: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 35-42: This else clause can be omitted because previous branches break early.

(lint/style/noUselessElse)

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 908dac6 and a2efae9.

Files selected for processing (1)
  • packages/synapse-interface/components/StateManagedBridge/AvailableBalance.tsx (2 hunks)
Additional context used
Biome
packages/synapse-interface/components/StateManagedBridge/AvailableBalance.tsx

[error] 27-42: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 35-42: This else clause can be omitted because previous branches break early.

(lint/style/noUselessElse)

Additional comments not posted (1)
packages/synapse-interface/components/StateManagedBridge/AvailableBalance.tsx (1)

3-3: LGTM! The import for formatAmount is correct.

The import statement for formatAmount from @/utils/formatAmount is appropriate and aligns with the changes described.

Copy link

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

(updates since last review)

  • .codecov.yml: Added carryforward: true to cctp-relayer flag for coverage data retention.
  • .yamllint.yml: Ignored index.yaml for YAML linting.
  • CONTRIBUTING.md: Advised using fetch-depth: 2 for shallow clones in GitHub Actions.
  • README.md: Added 'Widget' package under Synapse Bridge section.
  • agents/go.mod: Updated dependencies for improved compatibility and security.

164 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

@abtestingalpha abtestingalpha merged commit 67e255f into master Jul 17, 2024
53 checks passed
@abtestingalpha abtestingalpha deleted the fix/format-balance branch July 17, 2024 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants